using NUnit.Framework;
using ValidationFramework;

namespace ExampleLibraryCSharp.NewRule
{
    [TestFixture]
    public class RequiredCharacterRuleAttributeUsage
    {
        public class Person
        {

            [RequiredCharacterRule('s')]
            public string Name
            {
                get;
                set;
            }
        }

        [Test]
        public void Run()
        {
            var person = new Person();
            var propertyValidationManager = new PropertyValidationManager(person);

            propertyValidationManager.Validate("Name");
            // Valid because Name is Null
            Assert.IsTrue(propertyValidationManager.IsValid);

            person.Name = "john";
            propertyValidationManager.Validate("Name");
            // Invalid because Name does not contain an 's'
            Assert.IsFalse(propertyValidationManager.IsValid);

            person.Name = "simon";
            propertyValidationManager.Validate("Name");
            // Valid because Name does contain an 's'
            Assert.IsTrue(propertyValidationManager.IsValid);
        }
    }
}
